<?php

namespace Xin\Logger\Hyperf;

use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Logger\LoggerFactory;
use Xin\Logger\Logger;
use function Hyperf\Support\make;

class ConfigProvider
{
    /**
     * @return array
     */
    public function __invoke(): array
    {
        Logger::setDefaultLoggerResolver(function ($name) {
            return ApplicationContext::getContainer()->get(LoggerFactory::class)->get($name);
        });
        Logger::setDatabaseLoggerResolver(function ($name) {
            return new DatabaseLogger($name);
        });
        Logger::setStdoutLoggerResolver(function (){
            return make(StdoutLogger::class);
        });
        return [];
    }
}
